<!-- INCLUDE cms/output/header_body.html -->

<!-- INCLUDE cms/users/output/option_bar_body.html -->

<section class="full-content">
	<form method="post" action="cms.php?p=users&act=add" id="form-add-user">
		<article>
			<div class="head">Add a new user</div>
			<div class="form-box">
				<div class="row">
					<div class="left">Username:</div>
					<div class="right">
						<input type="text" name="username" value="" />
					</div>
				</div>
				
				<div class="row">
					<div class="left">Password:</div>
					<div class="right">
						<input type="password" name="password" value="" />
					</div>
				</div>
				
				<div class="row">
					<div class="left">Confirm Password:</div>
					<div class="right">
						<input type="password" name="password2" value="" />
					</div>
				</div>
				
				<div class="row">
					<div class="left">E-mail:</div>
					<div class="right">
						<input type="text" name="email" value="" />
					</div>
				</div>
				
				<div class="row">
					<div class="left">User Level:</div>
					<div class="right">
						<select name="level">
							<option value="0" selected="selected">Normal</option>
							<option value="1">Administrator</option>
						</select>
					</div>
				</div>
			</div>
		</article>
		
		<article>
			<div class="head">Actions</div>
			<div class="content">
				<div class="form-box">			
					<div class="row">
						<div class="single">
							<input type="submit" name="submit" value="Opslaan" />
							<input type="reset" name="reset" value="Reset" />
						</div>
					</div>
				</div>
			</div>
		</article>
		
		<article>
			<a class="close-window hover">Close Window</a>
		</article>
	</form>
</section>

<script type="text/javascript">
$('.close-window').click(function(){
	$.unblockUI();	
});

$("#form-add-user").submit(function(event){
	event.preventDefault();

	var $form	= $(this),
	userName	= $form.find('input[name="username"]').val(),
	userPass 	= $form.find('input[name="password"]').val(),
	userMail 	= $form.find('input[name="email"]').val(),
	userLevel 	= $form.find('select[name="level"]').val(),
	url			= $form.attr('action');
	
	var posting = $.post(url, {username:userName, password:userPass, email:userMail, level:userLevel, submit:true});
	
	posting.done(function(data){
		var content = $(data).find('#content');
		$('#result').empty().append(content);
		$.unblockUI();	
		$.growlUI('Succes!', 'User ' + userName + ' has been succesfully added!');
		$('#full').load('cms.php?p=users&ajax=true');
	});
});
	
</script>

<!-- INCLUDE cms/output/footer_body.html -->